//
//  Tools.h
//  AiMeiTu
//
//  Created by apple on 2018/6/6.
//  Copyright © 2018年 zpf. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef void(^ToolsBlock)(id respond);


@interface Tools : NSObject

#pragma mark - public
//通过文字来计算文字所占的区域大小
+ (CGSize)sizeForText:(NSString *)text withFont:(UIFont *)font withSize:(CGSize)size;

//设置行距
+(NSAttributedString *)getAttributedStringWithString:(NSString *)string lineSpace:(CGFloat)lineSpace;

//设置控件部分圆角 UIRectCornerTopLeft、UIRectCornerTopRight、UIRectCornerBottomLeft、UIRectCornerBottomRight
+ (void)setRoundAngleView:(UIView *)aView cornerRadius:(CGFloat)radius byRoundingCorners:(UIRectCorner)corners;


//通过文件名获取文件路径
+ (NSString *)filePathWithFileName:(NSString *)fileName;

//十六进制颜色
//+ (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha;
+ (UIColor *) colorWithHexString: (NSString *)color;

//获取当前时间戳
+(double)getCurrentTimeStamp;
//时间转date
+(NSDate *)getDate:(NSString *)datestr;
//时间戳转化制定格式时间
+(NSString *)dateWithTime:(NSString *)timeStr type:(NSString *)type;
//不同格式时间转换 默认原来的是yyyyMMddHHmmss
+(NSString *)dateWithTime:(NSString *)timeStr OriginalFormatter:(NSString *)oriFormatterStr expectFormatter:(NSString *)expFormatterStr;

//四舍五入
+(NSInteger)RoundingOff:(CGFloat)floatValue;

//MD5加密
+(NSString *)MD5WithString:(NSString *)str;
//sha1加密
+ (NSString *)sha1WithString:(NSString *)input;
//MD5+sha1 MD5外层
+ (NSString *)sha1_md5WithString:(NSString *)input;

//对称加密AES 128位
+ (NSString *)AES_EncryptWithString:(NSString *)input;
//解密
+ (NSString *)AES_DecryptWithString:(NSString *)input;

//根据图片二进制流获取图片格式
+ (NSString *)typeForImageData:(NSData *)data;

//获取缓存大小
+ (CGFloat)getCacheSize;

//清除缓存
+ (void)clearAllCacheSucc:(ToolsBlock)succBlock;

//关闭上拉下拉
+ (void)endRefreshWithTable:(UITableView *)tableView;
+ (void)endRefreshWithCollect:(UICollectionView *)collect;

//s转hh:mm:ss
+ (NSString *)getHmsWithDisTime:(NSInteger)disTime;

#pragma mark - app private
+(UIImage *)getImageSizeToMin:(UIImage *)img;
// 根据图片url获取图片尺寸
+(CGSize)getImageSizeWithURL:(id)imageURL;
//判断是否有网络
+ (BOOL)CheckNetWork;

//判断是否登录
+ (BOOL)IsLogin;

//判断手机格式
+ (BOOL)isValidPhone:(NSString *)phone;


+ (CGImageRef)drawImage:(CGImageRef)cgimage;

+ (CGFloat)safeAreaInsetsbottom;

+ (CGFloat)safeAreaInsetstop;

+ (NSDictionary *)dealWithNullData:(NSDictionary *)dic;
+ (NSArray *)dealWithNullDataArr:(NSArray *)arr;

+ (NSString *)NumberToShowString:(long)number;

+ (NSString *)imageNameMoshi:(NSString *)name;

+ (NSString *)inputTimeStr:(NSString *)timeStr;
+ (NSString*)weekdayStringFromDate:(NSDate*)inputDate;
+ (BOOL)isYesterdayWithDate:(NSDate *)newDate;

+ (NSURL *)urlToNsurl:(NSString *)str;
@end










